package com.hdf.etdemo.friend;

import java.util.ArrayList;
import java.util.List;

import com.hdf.easytools.base.EasyToolsActivity;
import com.hdf.easytools.view.listview.ListViewNoScroll;
import com.hdf.easytools.view.scrollview.DampView;
import com.hdf.etdemo.R;
import com.hdf.etdemo.friend.adapter.FriendListAdapter;
import com.hdf.etdemo.friend.entity.FriendEntiy;

import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.widget.AdapterView;
import android.widget.ImageView;
import android.widget.ListView;
import android.widget.Toast;
import android.widget.AdapterView.OnItemClickListener;

public class FriendActivity extends EasyToolsActivity {
	private ListView friendLv;
	private FriendListAdapter friendAdapter;
	private List<FriendEntiy> appList=new ArrayList<FriendEntiy>();

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.activity_friend);
		initView();
	}
	private void initView()
	{
		/** 设置标题显示 */
		this.TitleVisib(0, 1, 1, 1, 0);
		/** 绑定标题点击事件 */
		this.TitleClick(0, 1, 0, 1, 0);
		/** 设置标题样式ʽ */
		this.TitleStyle(null, R.drawable.et_back, "朋友圈", "写心情", 0);
		TiTRight.setTextColor(getResources().getColor(R.color.white));
		
		
		friendLv=(ListView) findViewById(R.id.friendlv);
		initData();
		friendAdapter=new FriendListAdapter(this, appList);
		friendLv.setAdapter(friendAdapter);
		friendLv.setOnItemClickListener(new OnItemClickListener() {
			@Override
			public void onItemClick(AdapterView<?> arg0, View arg1, int arg2,long arg3) {
				Toast.makeText(FriendActivity.this, "点击了第"+(arg2+1)+"项", Toast.LENGTH_LONG).show();
			}
		});
	}
	private String imgs1;
	private String imgs2;
	private String imgs3;
	private String imgs4;
	private String imgs5;
	private String imgs6;
	private void initData() {
			/*
			 * 添加模拟数据，正常情况下，这些数据是从服务端获取的
			 * 此次添加了七条数据，对应Gridview中图片数量
			 */
			//模拟用户发布的图片，路径用"#"隔开
			imgs1="http://i12.tietuku.com/5c3c305ea1262ae7.jpg";
			imgs2="http://t10.baidu.com/it/u=374721516,1427740298&fm=58#http://i12.tietuku.com/5c3c305ea1262ae7.jpg";
			imgs3="http://i12.tietuku.com/5c3c305ea1262ae7.jpg#http://t10.baidu.com/it/u=374721516,1427740298&fm=58#http://t11.baidu.com/it/u=3158457091,3429860559&fm=58";
			imgs4="http://i12.tietuku.com/5c3c305ea1262ae7.jpg#http://t10.baidu.com/it/u=374721516,1427740298&fm=58#http://t11.baidu.com/it/u=3158457091,3429860559&fm=58#http://t12.baidu.com/it/u=732128477,3149312025&fm=58";
			imgs5="http://i12.tietuku.com/5c3c305ea1262ae7.jpg#http://t10.baidu.com/it/u=374721516,1427740298&fm=58#http://t11.baidu.com/it/u=3158457091,3429860559&fm=58#http://t12.baidu.com/it/u=732128477,3149312025&fm=58#http://t11.baidu.com/it/u=2722915642,3232472693&fm=58";
			imgs6="http://i12.tietuku.com/5c3c305ea1262ae7.jpg#http://t10.baidu.com/it/u=374721516,1427740298&fm=58#http://t11.baidu.com/it/u=3158457091,3429860559&fm=58#http://t12.baidu.com/it/u=732128477,3149312025&fm=58#http://t11.baidu.com/it/u=2722915642,3232472693&fm=58#http://t12.baidu.com/it/u=1313963321,225077119&fm=58";
			
			FriendEntiy entiy=null;
			for(int i=0;i<7;i++){
				entiy=new FriendEntiy();
				switch (i) {
				case 0:
					entiy.setFname("刘亦菲");
					entiy.setFicon("http://i12.tietuku.com/5c3c305ea1262ae7.jpg");
					entiy.setFcontent("简单工具包 http://www.apkbus.com/android-250381-1-1.html?fromuid=706548");
					entiy.setFtime("1分钟前");
					break;
				case 1:
					entiy.setFname("刘德华");
					entiy.setFicon("http://t10.baidu.com/it/u=2565424359,3856609610&fm=58");
					entiy.setFcontent("大家好，我是刘德华");
					entiy.setFtime("3分钟前");
					entiy.setFprice(getImage(imgs1));;
					Log.d("info", getImage(imgs1).get(0).toString());
					break;
				case 2:
					entiy.setFname("张学友");
					entiy.setFicon("http://t10.baidu.com/it/u=374721516,1427740298&fm=58");
					entiy.setFcontent("大家好，我是张学友");
					entiy.setFtime("5分钟前");
					entiy.setFprice(getImage(imgs2));;
					break;
				case 3:
					entiy.setFname("郭富城");
					entiy.setFicon("http://t11.baidu.com/it/u=3158457091,3429860559&fm=58");
					entiy.setFcontent("大家好，我是郭富城");
					entiy.setFtime("1小时前");
					entiy.setFprice(getImage(imgs3));;
					break;
				case 4:
					entiy.setFname("黎明");
					entiy.setFicon("http://t12.baidu.com/it/u=732128477,3149312025&fm=58");
					entiy.setFcontent("大家好，我是黎明");
					entiy.setFtime("2小时前");
					entiy.setFprice(getImage(imgs4));;
					break;
				case 5:
					entiy.setFname("金城武");
					entiy.setFicon("http://t11.baidu.com/it/u=2722915642,3232472693&fm=58");
					entiy.setFcontent("大家好，我是金城武");
					entiy.setFtime("昨天");
					entiy.setFprice(getImage(imgs5));;
					break;
				case 6:
					entiy.setFname("古天乐");
					entiy.setFicon("http://t12.baidu.com/it/u=1313963321,225077119&fm=58");
					entiy.setFcontent("大家好，我是古天乐");
					entiy.setFtime("前天");
					entiy.setFprice(getImage(imgs6));;
					break;
				}
				appList.add(entiy);//添加进list
			}
	}
	
	public List<String> getImage(String imgstr)
	{
		String[] imgs=imgstr.split("#");
		List<String> list=new ArrayList<String>();
		for(int i=0;i<imgs.length;i++){
			list.add(imgs[i]);
		}
		return list;
	}
	 @Override
		public void onClick(View v) {
			// TODO Auto-generated method stub
			switch (v.getId()) {
			case R.id.left_img:
				finish();
				break;
			case R.id.right_text:
				GoActivity(WritMoodActivity.class);
				break;
			default:
				break;
			}
		}
	
}
